<?php

/**
 * Sửa lại toàn bộ module NEWS
 * @author: Tuấn Anh
 * @date: 2011-09-10
 */
class News extends MX_Controller {

    var $parent_id = NULL;

    function __construct() {
        parent::__construct();
//        $this->output->enable_profiler(TRUE);
    }

    /**
     * Chuẩn bị layout, các phần dữ liệu cần thiết cho module này
     *
     * @param type $method
     * @param type $para1
     * @param type $para2
     */
    function dispatcher($method = NULL, $para1 = NULL, $para2 = NULL, $para3 = NULL) {
        $main_content = NULL;
        $layout = 'layout/news_layout';
        $current_url = '';
        $breadcrumbs = '';
        $lang = $this->_lang;
        $uri = '/' . $this->uri->uri_string();
        $options = array();
        $options['lang'] = $lang;
        $options['current_menu'] = $uri;

        switch ($method) 
        {
            case 'list_news' :
                $main_content = $this->get_news_list(array('page' => $para1, 'lang' => $lang));
                $breadcrumbs = modules::run('breadcrumbs/breadcrumbs_by_menus', array('uri' => $uri));
                if ($this->input->get('q') != '')
                    $current_url = get_url_by_lang($lang, 'search') . '@?q=' . str_replace(' ', '+', $this->input->get('q'));
                else
                    $current_url = get_url_by_lang($lang, 'search');
                break;
            case 'list_news_by_cat' :
                $options['cat_id'] = $para2;
                $main_content = $this->get_news_list(array('lang' => $para1, 'cat_id' => $para2, 'page' => $para3));
                if ($lang != 'vi')
                    $current_url = '/' . $lang . '/' . $this->uri->segment(2);
                else
                    $current_url = '/' . $this->uri->segment(1);
                $breadcrumbs = modules::run('breadcrumbs/breadcrumbs_categories', array('cat_id' => $para2));
                if($para2 == HIGHLIGHT_PROJECT)
                    $layout = 'layout/pages_layout';
                break;
            case 'news_detail' :
                $main_content = $this->get_news_detail(array('cat_id' => $para2, 'id' => $para3, 'lang' => $lang));
                $options['current_menu'] = '/' . $this->uri->segment(1) . '-n' . $para2;
                $options['cat_id'] = $para2;
                $options['news_id'] = $para3;
                $breadcrumbs = modules::run('breadcrumbs/breadcrumbs_news_detail', array('id' => $para3));
                if($para2 == HIGHLIGHT_PROJECT)
                    $layout = 'layout/pages_layout';
                break;
        }

        $view_data                  = modules::run('pages/pages/get_genaral_content', $options);
        $view_data['left_menus']    = $this->_get_left_content($options);
        $view_data['url']           = isset($current_url) ? $current_url : '';
        $view_data['breadcrumbs']   = $breadcrumbs;
        $view_data['main_content']  = $main_content;

        $view_data['title']         = $this->_title;
        $view_data['keywords']      = $this->_keywords;
        $view_data['description']   = $this->_description;
        $view_data['h1']            = $this->_h1;
        $view_data['lang']          = $lang;

        if (MOBILE_SITE) {
            $view_data['main_menu']          = modules::run('menus/menus/get_mobile_main_menus', $options);
            $layout = 'mobile/content_layout';
        }
        $this->load->view($layout, $view_data);
    }
    
    function _get_left_content($options = array())
    {
        $output = '';
        $output .= modules::run('menus/menus/get_left_menus', $options);
        $output .= modules::run('supports/supports/get_supports', $options);
        return $output;
    }

    /**
     * Trả lại menu là danh sách các Danh mục tin tức
     * @author Tuấn Anh
     * @date 2011-09-10
     * @param type $options
     * @return type
     */
    
    
    function get_case_list($options = array()) {
        $options = $this->_get_data_from_filter($options);
        $options['search'] = $this->input->get('q');
        $view_data = $this->_get_news($options);

        $view_data['post_uri'] = '/' . $this->uri->segment(1);
        // header
        $this->_title = $options['title'] . DEFAULT_TITLE_SUFFIX;
        $this->_keywords = $options['keywords'];
        $this->_description = $options['description'];

        $layout = MOBILE_SITE ? 'mobile/news_list' : 'news/case_list';

        return $this->load->view($layout, $view_data, TRUE);
    }

function get_categories_list_mobile($option = array()) {           
    $category = $this->news_categories_model->get_news_categories_array($option);
        if (count($category) > 1)
            $option['parent_id'] = $category;
        $new_per_page = NEWS_PER_PAGE;
        if (!isset($option['cat_id']))
            $option['cat_id'] = DEFAULT_COMBO_VALUE;
        $option['parent_id'] = $option['cat_id'];
        $total_row = $this->news_categories_model->get_categories_count($option);
        $total_pages = (int) ($total_row / $new_per_page);
        if ($total_pages * $new_per_page < $total_row)
            $total_pages++;
//        if ((int) $option['page'] > $total_pages)
//            $option['page'] = $total_pages;
        $option['offset'] = $option['page'];
        $option['limit'] = $new_per_page;

        $config_paging = array();
        if (MOBILE_SITE) {

            /*
             * date : 2013-3-20
             * dzung.tt : Fix lỗi phân trang cho site mobile
             */
            $uri_segment = 2;
            $page_base_url = '';
            $arr = $this->uri->segment_array();

            foreach ($arr as $index => $val) {
                // dành cho phân trang dạng (trang|page)/(:num)
                if ($val === 'trang' or $val === 'page') {
                    unset($arr[$index]);
                    if (isset($arr[$index + 1]))
                        unset($arr[$index + 1]);
                    $uri_segment = $index + 1;
                }
                // dành cho phân trang dạng (trang|page)-(:num)
                if (preg_match('/^(trang|page)-(\d+)$/', $val)) {
                    unset($arr[$index]);
                    $uri_segment = $index + 1;
                }
            }

            if (!array_search('trang', $arr) or !array_search('page', $arr))
                $arr[] = 'trang';

            $page_base_url = base_url() . implode('/', $arr);

            //phân trang mobile dạng next - prev link
            $config_paging = prepare_pagination(
                    array(
                        'total_rows' => $total_row,
                        'per_page' => $option['limit'],
                        'uri_segment' => $uri_segment,
                        'base_url' => $page_base_url
                    )
            );
        } else {
            $config_paging = prepare_pagination(
                    array(
                        'total_rows' => $total_row,
                        'per_page' => $option['limit'],
                        'offset' => $option['offset'],
                        'js_function' => 'change_page'
                    )
            );
        }

        $this->pagination->initialize($config_paging);
        $view_data['categories'] = $this->news_categories_model->get_categories($option);
        $view_data['pagination'] = $this->pagination->create_links();
        return $this->load->view('mobile/categories_list', $view_data, TRUE);
    }
    
    function get_categories_list($option = array()) {
        
        $category = $this->news_categories_model->get_news_categories_array(array('parent_cat_id' => $option['parent_id'], 'lang' => $option['lang']));
        if (count($category) > 1)
            $option['parent_id'] = $category;
        $view_data['categories'] = $this->news_categories_model->get_categories($option);
        $cat = $this->news_categories_model->get_categories(array('id' => $option['parent_id'], 'last_row' => 1));
        $view_data['current_cat'] = $cat;
        if ($cat->parent_id != 0) {
            $parent_cat = $this->news_categories_model->get_categories(array('id' => $cat->parent_id, 'last_row' => 1));
            $view_data['bg_cat_color'] = $cat->bg_color != '' ? $cat->bg_color : $parent_cat->bg_color;
        } else {
            $view_data['bg_cat_color'] = $cat->bg_color != '' ? $cat->bg_color : 'F6F6F6';
        }
        
        $config = get_cache('configurations');
        $new_per_page = $config['news_per_page'] != 0 ? $config['news_per_page'] : NEWS_PER_PAGE;

        if (!isset($option['cat_id']))
            $option['cat_id'] = DEFAULT_COMBO_VALUE;
        $option['parent_id'] = $option['cat_id'];
        $total_row = $this->news_categories_model->get_categories_count($option);
        $total_pages = (int) ($total_row / $new_per_page);
        if ($total_pages * $new_per_page < $total_row)
            $total_pages++;
        if ((int) $option['page'] > $total_pages)
            $option['page'] = $total_pages;

        $option['offset'] = $option['page'] <= DEFAULT_PAGE ? DEFAULT_OFFSET : ((int) $option['page'] - 1) * $new_per_page;
        $option['limit'] = $new_per_page;

        $config_paging = array();
        if (MOBILE_SITE) {

            /*
             * date : 2013-3-20
             * dzung.tt : Fix lỗi phân trang cho site mobile
             */
            $uri_segment = 2;
            $page_base_url = '';
            $arr = $this->uri->segment_array();

            foreach ($arr as $index => $val) {
                // dành cho phân trang dạng (trang|page)/(:num)
                if ($val === 'trang' or $val === 'page') {
                    unset($arr[$index]);
                    if (isset($arr[$index + 1]))
                        unset($arr[$index + 1]);
                    $uri_segment = $index + 1;
                }
                // dành cho phân trang dạng (trang|page)-(:num)
                if (preg_match('/^(trang|page)-(\d+)$/', $val)) {
                    unset($arr[$index]);
                    $uri_segment = $index + 1;
                }
            }

            if (!array_search('trang', $arr) or !array_search('page', $arr))
                $arr[] = 'trang';

            $page_base_url = base_url() . implode('/', $arr);

            //phân trang mobile dạng next - prev link
            $config_paging = prepare_pagination(
                    array(
                        'total_rows' => $total_row,
                        'per_page' => $option['limit'],
                        'uri_segment' => $uri_segment,
                        'base_url' => $page_base_url
                    )
            );
        } else {
            $config_paging = prepare_pagination(
                    array(
                        'total_rows' => $total_row,
                        'per_page' => $option['limit'],
                        'offset' => $option['offset'],
                        'js_function' => 'change_page'
                    )
            );
        }

        $this->pagination->initialize($config_paging);
        $view_data['pagination'] = MOBILE_SITE ? $this->pagination->create_links() : $this->pagination->create_ajax_links();
        $layout = MOBILE_SITE ? 'mobile/categories_list' : 'list_category';
        return $this->load->view($layout, $view_data, TRUE);
    }

    function get_categories_menu($options = array()) {
        $view_data = array();
        $options['categories'] = $this->news_categories_model->get_categories($options);
        if (isset($options['parent_cat'])) {
            $cat = $this->news_categories_model->get_categories(array('id' => $options['parent_cat'], 'last_row' => 1));
            if ($cat->parent_id != 0) {
                $parent_cat = $this->news_categories_model->get_categories(array('id' => $cat->parent_id, 'last_row' => 1));
                if ($parent_cat->parent_id != 0) {
                    $grand_parent = $this->news_categories_model->get_categories(array('id' => $parent_cat->parent_id, 'last_row' => 1));
                    $options['parent_id'] = $parent_cat->parent_id;
                    $view_data['title'] = $grand_parent->category;
                } else {
                    $options['parent_id'] = $cat->parent_id;
                    $view_data['title'] = $parent_cat->category;
                }
            } else {
                $options['parent_id'] = $options['parent_cat'];
                $view_data['title'] = $cat->category;
            }
        } else {
            $options['parent_id'] = ROOT_CATEGORY_ID;
        }
        $view_data['cat_id'] = isset($options['cat_id']) ? $options['cat_id'] : '';
        $cat_menu = '';
        $cat_menu .= $this->_visit($options);
        $cat_menu .= '';
        $view_data['categories'] = $cat_menu;
        $view_data['categories'] = str_replace('<ul class="side_con"></ul>', '', $view_data['categories']);
        return $this->load->view('news/categories_menus', $view_data, TRUE);
    }

    function get_categories_menus2($options = array()) {
        $view_data = array();
        $cate_id = isset($options['cat_id']) ? $options['cat_id'] : NULL;

        $categories = $this->_get_custom_categories($cate_id);

        $view_data['title'] = __('IP_news_categories');
        $view_data['categories'] = $categories;

        return $this->load->view('news/categories_menus2', $view_data, TRUE);
    }

    private function _category_has_childs($cate_id = NULL) {
        
            $cate = $this->news_categories_model->get_categories(array('lang' => $this->_lang, 'parent_id' => $cate_id));
            if (count($cate) > 0) {
                return TRUE;
            }
            else {
                return FALSE;
            }
        
    }

    private function _get_custom_categories($cate_id = NULL) {
        if ($cate_id) {
            $cate = $this->news_categories_model->get_categories(array('id' => $cate_id, 'array' => TRUE, 'lang' => $this->_lang));
            $childs = $this->news_categories_model->get_categories(array('parent_id' => $cate_id, 'array' => TRUE, 'lang' => $this->_lang));
            if (!empty($cate)) {
                if (count($childs) > 0) {
                    $cate['childs'] = $childs;
                    $categories[] = $cate;
                } else {
                    if ($cate['parent_id'] != ROOT_CATEGORY_ID) {
                        $childs = $this->news_categories_model->get_categories(array('parent_id' => $cate['parent_id'], 'array' => TRUE, 'lang' => $this->_lang));
                        $cate = $this->news_categories_model->get_categories(array('id' => $cate['parent_id'], 'array' => TRUE, 'lang' => $this->_lang));
                        $cate['childs'] = $childs;
                        $categories[] = $cate;
                    } else {
                        $categories = $this->news_categories_model->get_categories(array('parent_id' => ROOT_CATEGORY_ID, 'array' => TRUE, 'lang' => $this->_lang));
                    }
                }
            } else {
                $categories = $this->news_categories_model->get_categories(array('parent_id' => ROOT_CATEGORY_ID, 'array' => TRUE, 'lang' => $this->_lang));
            }
        } else {
            $categories = $this->news_categories_model->get_categories(array('parent_id' => ROOT_CATEGORY_ID, 'array' => TRUE, 'lang' => $this->_lang));
        }
        return $categories;
    }

    private function _visit($options = array()) {
        $output = '';
        $sub_cat = $this->_get_sub_cat($options);
        foreach ($sub_cat as $cat) {
//            $class = ($options['cat_id'] == $cat->id) ? 'active' : '';
            $has_child = $this->news_categories_model->get_categories(array('parent_id' => $cat->id));
            $style = count($has_child) > 0 ? '<hr class="li_con">' : "";
            $parent_cat = $this->news_categories_model->get_categories(array('id' => $cat->parent_id, 'last_row' => 1));
            if (($options['cat_id'] == $cat->id) && ($parent_cat->parent_id != 0))
                $class = 'active_s';
            elseif (($options['cat_id'] == $cat->id) && ($parent_cat->parent_id == 0)) {
                $class = 'active';
            } else {
                $class = '';
            }
//            $style1 = ($options['cat_id'] == $cat->id) && ($cat->parent_id!=0) ? ' active_s' : '';
            $img = $cat->parent_id == 0 ? '<img src="/images/bg_li.png">' : '';
            if (count($has_child) > 0 && $options['cat_id'] == $cat->id)
                $img = '<img src="images/bg_li_a.png">';
            $output .= '<li class="' . $class . '">';
            $output .= '<a href="' . get_base_url() . url_title($cat->category, 'dash', TRUE) . '-n' . $cat->id . '">' . $img;
            $output .= $cat->category . '</a>';
            $cate = $this->news_categories_model->get_categories(array('id' => $options['cat_id'], 'last_row' => 1));
            if (($options['cat_id'] == $cat->id) || $cat->id == $cate->parent_id) {
                $output .= '<ul class="side_con">';
                $options['parent_id'] = $cat->id;
                $output .= $this->_visit($options);
                $output .= '</ul></li>' . $style;
            } else {
                $output .= '</li>';
            }
        }
        return $output;
    }

    private function _get_sub_cat($options = array()) {
        $cats = $options['categories'];
        $sub_cat = array();
        foreach ($cats as $index => $cat) {
            if ($cat->parent_id == $options['parent_id'])
                $sub_cat[$index] = $cat;
        }
        return $sub_cat;
    }

    /**
     * Trả lại danh sách các tin tức
     * @author Tuấn Anh
     * @date 2011-09-10
     * @param type $options
     * @return type
     */
    
    public function get_news_detail_mobile($options = array()) {
        $view_data = array();
        $view_data['news'] = $this->news_model->get_news($options);
        $view_data['related_news'] = $this->get_related_news(array('flag'=>LATEST_NEWS,'cat_id'=>$options['cat_id']));
        $view_data['post_uri'] = '/' . $this->uri->segment(1);

        // header
        $this->_title = $options['title'] . DEFAULT_TITLE_SUFFIX;
        $this->_keywords = $options['keywords'];
        $this->_description = $options['description'];

        $layout = MOBILE_SITE ? 'mobile/news_detail' : 'news/news_detail';

        return $this->load->view($layout, $view_data, TRUE);
    }
    
    public function get_news_list($options = array()) 
    {
        
        $this->output->link_js('/scripts/stickyScroller/StickyScroller.min.js');
        $this->output->link_js('/scripts/stickyScroller/GetSet.js');
        $this->output->javascripts('sticky_scroller();');
        
        $options = $this->_get_data_from_filter($options);
        
        if(!isset($options['cat_id'])) $options['cat_id'] = DEFAULT_COMBO_VALUE;
        $options['parent_id']    = $options['cat_id'];
        $categories_array = $this->news_categories_model->get_news_categories_array($options);
        if(count($categories_array) > 0)
            $options['cats_id'] = $categories_array;
        unset($options['cat_id']);
        
        $options['search'] = $this->input->get('q');
        $view_data = $this->_get_news($options);

        $view_data['post_uri'] = '/' . $this->uri->segment(1);
        
        // header
        $this->_title       = $options['title'] . DEFAULT_TITLE_SUFFIX;
        $this->_keywords    = $options['keywords'];
        $this->_description = $options['description'];
        $this->_h1          = $view_data['h1'];

//        $layout = MOBILE_SITE ? 'mobile/news_list' : 'news/news_list';
        if($options['parent_id'] == HIGHLIGHT_PROJECT) 
            $layout = 'news/project_list';
        else
            $layout = 'news/news_list';
        return $this->load->view($layout, $view_data, TRUE);
    }

    /**
     * Trả lại danh sách các tin tức
     * @author Tuấn Anh
     * @date 2011-09-10
     * @param type $options
     * @return type
     */
    private function _get_news($options = array()) 
    {
        $config = get_cache('configurations');
        $new_per_page = $config['news_per_page'] != 0 ? $config['news_per_page'] : NEWS_PER_PAGE;
        
        $total_row = $this->news_model->get_news_count($options);
        $total_pages = (int) ($total_row / $new_per_page);
        if ($total_pages * $new_per_page < $total_row)
            $total_pages++;
        if ((int) $options['page'] > $total_pages)
            $options['page'] = $total_pages;

        $options['offset'] = $options['page'] <= DEFAULT_PAGE ? DEFAULT_OFFSET : ((int) $options['page'] - 1) * $new_per_page;
        $options['limit'] = $new_per_page;

        $config_paging = array();
        if (MOBILE_SITE) {

            /*
             * date : 2013-3-20
             * dzung.tt : Fix lỗi phân trang cho site mobile
             */
            $uri_segment = 2;
            $page_base_url = '';
            $arr = $this->uri->segment_array();

            foreach ($arr as $index => $val) {
                // dành cho phân trang dạng (trang|page)/(:num)
                if ($val === 'trang' or $val === 'page') {
                    unset($arr[$index]);
                    if (isset($arr[$index + 1]))
                        unset($arr[$index + 1]);
                    $uri_segment = $index + 1;
                }
                // dành cho phân trang dạng (trang|page)-(:num)
                if (preg_match('/^(trang|page)-(\d+)$/', $val)) {
                    unset($arr[$index]);
                    $uri_segment = $index + 1;
                }
            }

            if (!array_search('trang', $arr) or !array_search('page', $arr))
                $arr[] = 'trang';

            $page_base_url = base_url() . implode('/', $arr);

            //phân trang mobile dạng next - prev link
            $config_paging = prepare_pagination(
                    array(
                        'total_rows' => $total_row,
                        'per_page' => $options['limit'],
                        'uri_segment' => $uri_segment,
                        'base_url' => $page_base_url
                    )
            );
        } else {
            $config_paging = prepare_pagination(
                    array(
                        'total_rows' => $total_row,
                        'per_page' => $options['limit'],
                        'offset' => $options['offset'],
                        'js_function' => 'change_page'
                    )
            );
        }

        $this->pagination->initialize($config_paging);


        $view_data                  = array();
        $news                       = $this->news_model->get_news($options);
        $view_data['news']          = $news;
        $view_data['pagination']    = MOBILE_SITE ? $this->pagination->create_links() : $this->pagination->create_ajax_links();
        $view_data['title']         = $options['title'];
        $view_data['keywords']      = $options['keywords'];
//        $view_data['description']   = $options['description'];
        $view_data['h1']            = $options['title'];

        return $view_data;
    }

    /**
     * Chuẩn bị các dữ liệu cần thiết
     * @author Tuấn Anh
     * @date 2011-09-10
     * @param type $options
     * @return type
     */
    private function _get_data_from_filter($options = array()) {
        if (isset($options['cat_id']) && $options['cat_id'] != DEFAULT_COMBO_VALUE) {
            $category = $this->news_categories_model->get_categories(array('id' => $options['cat_id']));
            if (!is_object($category))
                return show_404();
            $options['cat_id'] = $category->id;

            // vào danh mục rồi nhưng chưa có meta_title
            if (is_object($category) && $category->meta_title == '') {
                $options['title'] = $category->category;
                $options['keywords'] = $options['title'];
                $options['description'] = $options['title'];
            } else {
                $options['title'] = $category->meta_title;
                $options['keywords'] = $category->meta_keywords;
                $options['description'] = $category->meta_description;
            }
        }
        if (!isset($options['title'])) {
            $options['title'] = __("IP_news_list");
            $options['keywords'] = $options['title'];
            $options['description'] = $options['title'];
        }
        return $options;
    }

    function get_news_detail($options = array(), & $extra = array()) 
    {
        $this->news_model->update_view($options['id']);

        $news = $this->news_model->get_news(array('id' => $options['id']));
        if (empty($news)) {
            show_404();
        }
        $extra['cat_id'] = isset($news->categories_id) && !empty($news->categories_id) ? $news->categories_id : ROOT_CATEGORY_ID;
        $lastest_news['title']  = 'Các tin liên quan';
        $lastest_news['news']   = $this->news_model->get_news(array('except_id' => $news->id, 
                                                                    'cat_id'    => $options['cat_id'],
                                                                    'limit'     => RELATED_NEWS_LIMIT));

        $view_data['lastest_news']  = $this->load->view('related_news', $lastest_news, TRUE);
        $view_data['news'] = $news;
//        if ($news->tags != '')
//            $view_data['tags'] = genarate_tags($news->tags, 'tin-tuc');

        $view_data['title'] = $news->meta_title != '' ? $news->meta_title : $news->title;
        //header
        $this->_title       = ($news->meta_title != '' ? $news->meta_title : $news->title) . DEFAULT_TITLE_SUFFIX;
        $this->_keywords    = $news->meta_keywords != '' ? $news->meta_keywords : $news->title;
        $this->_description = strip_tags($news->meta_description != '') ? strip_tags($news->meta_description) : strip_tags($news->summary);
        $this->_h1          = $news->meta_title != '' ? $news->meta_title : $news->title;

//        $layout = MOBILE_SITE ? 'mobile/news_detail' : 'news/news_detail';
        
        if($options['cat_id'] == HIGHLIGHT_PROJECT) 
        {
            $this->output->link_css('/css/fancybox/jquery.fancybox-1.3.4.css');
            $this->output->link_js('/powercms/scripts/fancybox/jquery.fancybox-1.3.4.pack.js');
            $this->output->javascripts('show_fancy_box();');
            $layout = 'news/project_detail';
        }
        else
        {
            $this->output->link_js('/scripts/stickyScroller/StickyScroller.min.js');
            $this->output->link_js('/scripts/stickyScroller/GetSet.js');
            $this->output->javascripts('slide_scroll();');
            $this->output->javascripts('sticky_scroller();');
            $layout = 'news/news_detail';
        }

        return $this->load->view($layout, $view_data, TRUE);
    }

    function get_latest_news($options = array()) {
        $config = get_cache('configurations');
        $options['limit'] = $config['news_side_per_page'] != 0 ? $config['news_side_per_page'] : LATEST_NEWS;
        $options['lang'] = $this->_lang;
        $options['show_homepage'] = TRUE;
        $view_data = array();
        $view_data['news'] = $this->news_model->get_news($options);
        return $this->load->view('news/latest_news', $view_data, TRUE);
    }

    function get_related_news($options = array()) {
        $options['limit'] = RELATED_NEWS_LIMIT;
        $view_data = array();
        $view_data['news'] = $this->news_model->get_news($options);
        return $this->load->view('news/mobile/related_news', $view_data, TRUE);
    }
    
    function get_news_hp($options = array())
    {
        $options['cat_id'] = SERVICE;
        $view_data = array();
        $view_data['news'] = $this->news_model->get_news($options);
        return $this->load->view('news/news_hp', $view_data, TRUE);
    }
}
